package mypack.srverlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.GenericServlet;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import org.apache.log4j.Logger;

public class HelloServlet1 extends GenericServlet{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private String username=null;
	
	
	@Override
	public void service(ServletRequest request, ServletResponse response)
			throws ServletException, IOException {
		Logger logger = Logger.getLogger(HelloServlet1.class);
		username = request.getParameter("username");
		if(username!=null){
			username = new String(username.getBytes("ISO-8859-1"),"gb2312");
		}
        try {
			Thread.sleep(3000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		} 
		logger.info("do it ......");
        response.setContentType("text/html;charset=GB2312");
        PrintWriter out = response.getWriter();
        out.println("<html><body>");
        out.println("你好:"+username);
        out.println("</body></html>");
        out.close();
	}

}
